GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 1094b2...af4f1c )
by Vladimir
36s
created

index.test.js ➔ ???   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 81

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 1
c 5
b 0
f 0
nc 1
dl 0
loc 81
rs 8.8076
nop 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.test.js ➔ ... ➔ ??? 0 14 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/** global: jest */
2
3
const router = require('./../../../src/routes/index');
4
5
describe('Index routes.', () => {
6
  test('GET homepage', (done) => {
7
    const request = {
8
      method: 'GET',
9
      url: '/',
10
    };
11
    const response = {
12
      redirect: (targetUrl) => {
13
        expect(targetUrl).toMatch(/.+/);
14
        done();
15
      },
16
    };
17
18
    router.handle(request, response);
19
  });
20
21
  test('GET page by streamId', (done) => {
22
    const request = {
23
      method: 'GET',
24
      url: '/testId',
25
    };
26
    const response = {
27
      render: (tpl, data) => {
28
        expect(tpl).toBe('index');
29
        expect(typeof data).toBe('object');
30
        done();
31
      },
32
    };
33
34
    router.handle(request, response);
35
  });
36
37
  /**
38
   * This block describes test cases related to POSTing data into page.
39
   */
40
  describe('POST data into page with certain streamId.', () => {
41
    test('POST plain text', (done) => {
42
      const request = {
43
        method: 'POST',
44
        url: '/testId',
45
        headers: {
46
          'x-forwarded-for': 'testIp',
47
          'content-type': 'text',
48
        },
49
        body: 'Test with plain text body.',
50
      };
51
      const response = {
52
        status: jest.fn(),
53
        send: () => done(),
54
      };
55
56
      router.handle(request, response);
57
    });
58
59
    test('POST JSON data', (done) => {
60
      const request = {
61
        method: 'POST',
62
        url: '/testId',
63
        headers: { 'content-type': 'application/json' },
64
        connection: {
65
          socket: { remoteAddress: 'testIp' },
66
        },
67
        socket: {},
68
        body: '{"decs": "JSON data"}',
69
      };
70
      const response = {
71
        status: jest.fn(),
72
        send: jest.fn(),
73
      };
74
      global.socket = {
75
        emit: (type, data) => {
76
          expect(type).toBe('log');
77
          expect(typeof data).toBe('object');
78
          done();
79
        },
80
      };
81
82
      router.handle(request, response);
83
    });
84
  });
85
});
86